This article mainly introduces some new HTML5 features and the sorting of common Canvas attributes. CanvasAPI is an important part of HTML5 for drawing graphics. For more information, see
1. HTML5 content type
Content type
Description
Embedded
Add other types of content to the document, such as audio, video, canvas, and iframe.
much, this "piece" of how big.Second partSecondly, I have said before the canvas this label itself is not drawing ability, need to borrow Java scrip power. So the second step is to write the JS code. Here's a simple red rectangle for you to draw. The code is as followsIt is important to note that although Var has two objects, it still needs to be written in specification. Can not use a simple ABC to replace, as far as possible to see the name of unde
Offsetctx.shadowoffsety=8;//Vertical Offsetctx.shadowblur=10;//Blur Radius4. Use gradient color when drawingCtx.createlineargradient (X1,Y1,X2,Y2): Creating a linear Gradient objectCtx.createradialgradient (X1,Y1,R1,X2,Y2,R2): Creating a Radial Gradient objectCtx.addcolorstop: Adding color points5. Draw the pathCtx.beginpath (): Start pathCtx.closepath (): End PathCtx.moveto (x, y): Move to a specified pointCtx.lineto (x, y): Draw a straight path to a specified pointCtx.arc (): Drawing an arche
(), LineTo (), MoveTo (), Quadraticcurveto (), rect () , then select: Closepath () method, fill (), stroke () after the path is created.
Draw the clock:12
Draw Text : Filltext () and Stroketext () four parameters: The text character to be drawn, the x-coordinate, the y-coordinate, and the optional maximum pixel width. Properties: Font (Text style, size, font), textAlign (text alignment), Textbaseline (baseline of text).
1 Context.font= "Bold 14px Arial"; 2 con
1, the understanding of canvasThe canvas is a rectangular area within which the pixel control of each frame within the area can be controlled by JS.2. js Operation Canvas ObjectCanvas object. GetContext ("2d");//Get Canvas contentSet gradientvar grd=cxt.createlineargradient (0,0,175,50);Grd.addcolorstop (0, "#FF0000")Grd.addcolorstop (1, "#00FF00");Ctx.fillstyle/
Before we mentioned the red rectangles drawn in the JS code, we now use the code to see what it means. The code is as followsVarcontext=c.getcontext ("2d");Context.fillstyle= "#FF0000";Context. FillRect (0,0,150,75);in fact, a slightly stronger understanding of the small partner should be seen, in the first row is to get the canvas object, and the second row of the GetContext ("2d") object is built-in HTML5 object, with a variety of drawing paths, rec
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.